<!--
 * @Author: 赵宇
 * @Description: 
 * @Date: 2024-01-08 09:09:22
 * @LastEditTime: 2025-02-25 23:14:19
 * @LastEditors: zhao 13370229059@163.com
 * @FilePath: \dance\App.vue
-->
<script>
  export default {
    onLaunch: function () {
      // 非开发工具移除
      let envVersion = '';
      // #ifdef MP-WEIXIN
      const { miniProgram } = uni.getAccountInfoSync();
      envVersion = miniProgram.envVersion;
      // #endif

      if (envVersion === 'release') {
        console.log = () => {};
        console.info = () => {};
        console.error = () => {};
        console.warn = () => {};
      }
    },
    onShow: function () {
      uni.removeStorageSync('selectedIndex'); // 清除缓存

      // #ifdef MP-WEIXIN
      const updateManager = wx.getUpdateManager();

      updateManager.onCheckForUpdate(function (res) {
        if (res.hasUpdate) {
          // 有新版本，需要更新
          updateManager.onUpdateReady(function () {
            wx.showModal({
              title: '更新提示',
              content: '新版本已经准备好，重启应用以完成更新。确定么？',
              success: function (res) {
                if (res.confirm) {
                  // 用户确认重启
                  updateManager.applyUpdate();
                }
              }
            });
          });

          updateManager.onUpdateFailed(function () {
            // 新版本下载失败
            wx.showModal({
              title: '更新失败',
              content: '新版本下载失败，请检查网络设置或稍后再试！'
            });
          });
        }
      });
      // #endif
    },
    onShow: function () {},
    onHide: function () {}
  };
</script>

<style lang="scss">
  @import '@/static/iconfont.css';
  @import '@/uni_modules/uv-ui-tools/index.scss';
  .uni-tabbar .uni-tabbar__icon {
    width: 40rpx !important;
    height: 40rpx !important;
  }
</style>
